//
// Copyright (c) 2024 BPer
//
#ifndef __BPerOpenH264Encoder__
#define __BPerOpenH264Encoder__
#include <bperencoder/BPerVideoEncoder.h>
#include <bperutil/buffer/BPerVideoBuffer.h>
#include <bperutil/buffer/BPerVideoEncoderBuffer.h>
#include <wels/codec_api.h>

class BPerOpenH264Encoder: public BPerVideoEncoder {
public:
	BPerOpenH264Encoder();
	~BPerOpenH264Encoder(void);

	int32_t init(BPerContext* pcontext,BPerVideoInfo* pvideoInfo);

	void setVideoMetaData(BPerVideoMeta *pvmd);
	void parseRtmpHeader(uint8_t *p, int32_t pLen, int32_t *pwid, int32_t *phei, int32_t *pfps);
	void sendMsgToEncoder(BPerRtcEncoderMessage *msg);
private:

	int32_t m_sendKeyframe;
	int32_t encode(BPerFrame* pframe, BPerEncoderCallback* pcallback);
protected:

	ISVCEncoder *m_264Handle;


	SSourcePicture m_pic;
	SFrameBSInfo m_einfo;
	int32_t m_yuvLen;
	int32_t m_vlen;


private:

	bool m_hasHeader;

};
#endif
